/**
 *	all functions related to viewing the game and the game UI
**/

if (typeof Controllers === "undefined") {
	var Controllers = { }
}

Controllers.GamePage = {
	
	setup: function(game) {
		var el = {
			player1: document.getElementById('GPplayer1'),
			player2: document.getElementById('GPplayer2'),
		}
		
		el.player1.innerText = game.players[0]
		el.player2.innerText = game.players[1]
	},
	
	quit: function() {
		API.kill()
		Game.game.winner = -1								//set to draw - stop the game checker from running in the background
		
		Main.goTo('MatchPage')							//back to the match making page
	},
	
	//logs gameplay errors and notices to the user
	userLog: function(str) {
		if (!this._console) {
			this._console = document.getElementById('Console')
		} else if (typeof str !== "string") {
			throw str
		}
		
		this._console.innerHTML += "<p>" + str + "</p>"
		this._console.scrollTop = this._console.scrollHeight
	},
	
	playerTurn: function(playerno) {
		var el = {
			player1: document.getElementById('GPplayer1'),
			player2: document.getElementById('GPplayer2'),
		}
		
		el.player1.className = 'player' + ( playerno === 1 ? ' selected' : '' )
		el.player2.className = 'player' + ( playerno === 2 ? ' selected' : '' )
	}
	
}